package gold.digger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC784 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public List<String> letterCasePermutation(String s) {
            return dfs(s, 0);
        }

        private List<String> dfs(String s, int i) {
            List<String> result = new ArrayList<>();
            if (i == s.length() - 1) {
                String s1 = ("" + s.charAt(i)).toLowerCase();
                String s2 = ("" + s.charAt(i)).toUpperCase();
                if (s1.equals(s2)) {
                    result.add(s1);
                } else {
                    result.add(s1);
                    result.add(s2);
                }
            } else {
                List<String> rest = dfs(s, i + 1);
                String s1 = ("" + s.charAt(i)).toLowerCase();
                String s2 = ("" + s.charAt(i)).toUpperCase();
                for (String r : rest) {
                    if (s1.equals(s2)) {
                        result.add(s1 + r);
                    } else {
                        result.add(s1 + r);
                        result.add(s2 + r);
                    }
                }
            }
            return result;
        }
    }


    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC784 an = new LC784();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
